package com.dtd.market.product.action;

import java.io.InputStream;

import org.apache.commons.io.IOUtils;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.dtd.market.common.BaseAction;

@SuppressWarnings("serial")
@Namespace("/product")
@Results( { 
	@Result(name = BaseAction.INDEX, location = "index.jsp") 
})
public class IndexAction extends BaseAction {

	private static Logger logger = LoggerFactory.getLogger(IndexAction.class);
	private Integer start;
	private Integer limit;
	private String uuid;

	public Integer getStart() {
		return start;
	}

	public void setStart(Integer start) {
		this.start = start;
	}

	public Integer getLimit() {
		return limit;
	}

	public void setLimit(Integer limit) {
		this.limit = limit;
	}
	
	public String getUuid() {
		return uuid;
	}

	public void setUuid(String uuid) {
		this.uuid = uuid;
	}
	
	public void list() throws Exception {
		InputStream is = getContext().getServletContext().getResourceAsStream("/mock/list.json");
		String result = IOUtils.toString(is);
		logger.debug(start + ":" +limit);
		logger.debug(result);
		renderJson(result);
	}

	public void delete() {
		logger.debug(uuid);
		renderText(SUCCESS);
	}

}
